package com.mpgame.database.mysql.mapper.game;

import com.mpgame.database.mysql.mapper.BaseMapper;
import com.mpgame.database.mysql.model.game.SceneInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SceneInfoMapper extends BaseMapper<SceneInfo> {
    
    @Insert("INSERT INTO scene_info (name, scene_name, envinfo_url) VALUES (#{name}, #{sceneName}, #{envinfoUrl})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(SceneInfo sceneInfo);

    @Select("SELECT * FROM scene_info WHERE id = #{id}")
    SceneInfo selectById(@Param("id") int id);

    @Select("SELECT * FROM scene_info WHERE name = #{name}")
    SceneInfo selectByName(@Param("name") String name);

    @Select("SELECT * FROM scene_info WHERE scene_name = #{sceneName}")
    SceneInfo selectBySceneName(@Param("sceneName") String sceneName);

    @Select("SELECT * FROM scene_info")
    List<SceneInfo> selectAll();

    @Update("UPDATE scene_info SET name = #{name}, scene_name = #{sceneName}, envinfo_url = #{envinfoUrl} WHERE id = #{id}")
    int updateById(SceneInfo sceneInfo);
}

